<?php 

namespace slinks\extensions\amf\zend;

/**
 * Extends Zend_Server_Reflection_Method to allow amf RemoteMethods to be invoked directly from a slinks container. 
 * 
 * NOTE: this class should not be used as a general replacement for Zend_Server_Reflection_Method since it purposely brekas some functionality. 
 *       This is done so we can extend the Zend_Amf_Server without modifications to the Zend code. 
 *       
 * @author Navid Mitchell
 *
 */
class ServiceAwareZendServerReflectionMethod extends \Zend_Server_Reflection_Method {
	
	private $methodName; 
	
    public function __construct(ServiceAwareZendServerReflectionClass $class, $methodName){
	   
       $this->_classReflection = $class;
	   $this->methodName = $methodName;
	   
	   // not really sure why parent does this but we can too
	   $this->_class = $class->getName();
	   
	   // use class namespace. 
       $this->setNamespace($class->getNamespace());
	}
	
	
	public function invokeArgs($object, array $args ){
	   // if (method_exists($object, $this->methodName)) {
            return call_user_func_array(array($object, $this->methodName), $args);
       // }else{
        //	throw new \BadMethodCallException('Method '.$this->methodName.' not implemented for '.$this->_classReflection->getName().'.');
       // }
	}
	
    public function getName(){
    	return $this->methodName;
    }
    
    public function isStatic(){
    	return false;
    }
	
}


